for now.
That'll teach me to trust pre-releases. Grrr.
/* Define to 1 if you have the `sleep' function. */
#undef HAVE_SLEEP
+/* Define to 1 if you have the `glob' function. */
+#undef HAVE_GLOB
+
/* Define to 1 if you have the `uname' function. */
#undef HAVE_UNAME
# AC_FUNC_STRTOD
# AC_FUNC_VPRINTF
# AC_CHECK_FUNCS([atexit floor localtime_r memmove memset pow select sqrt strchr strcspn strdup strerror strncasecmp strrchr strspn strstr strtol strtoul])
-AC_CHECK_FUNCS([nanosleep sleep uname])
+AC_CHECK_FUNCS([nanosleep sleep uname glob])
#
# Checks for how the system handles va_list
return inifile_readstr(inifile, section, key);
}
-mag_info *
-explorist_ini_get() {
- mag_info *info = xmalloc(sizeof(mag_info));
+static mag_info *
+explorist_ini_try(const char *path) {
+ mag_info *info = NULL;
+ char *inipath;
char *s;
- inifile = inifile_init("Geocaches.ini", myname);
- s = xstrdup(inifile_readstr(inifile, "Geocaches", "GeocachesPath"));
- s = gstrsub(s, "\\", "/");
- info->geo_path = s;
- inifile_done(inifile);
+ xasprintf(&inipath, "%s/%s", path, "APP/Atlas.ini");
+ inifile = inifile_init(inipath, myname);
+ if (!inifile) {
+ xfree (inipath);
+ return NULL;
+ }
- inifile = inifile_init("Tracks.ini", myname);
- s = xstrdup(inifile_readstr(inifile, "Tracks", "TracksExportPath"));
- s = gstrsub(s, "\\", "/");
- info->track_path = xstrappend(s, "/tracks.gpx");;
- inifile_done(inifile);
+ info = xmalloc(sizeof(mag_info));
+ info->geo_path = NULL;
+ info->track_path = NULL;
+ info->waypoint_path = NULL;
- inifile = inifile_init("Waypoints.ini", myname);
- s = xstrdup(inifile_readstr(inifile, "Waypoints", "WaypointsPath"));
- s = gstrsub(s, "\\", "/");
- info->waypoint_path = xstrappend(s, "/newwaypoints.gpx");
- inifile_done(inifile);
+ s = xstrdup(inifile_readstr(inifile, "UGDS", "WpFolder"));
+ if (s) {
+ s = gstrsub(s, "\\", "/");
+ xasprintf(&info->waypoint_path, "%s/%s", path, s);
+ }
+ s = xstrdup(inifile_readstr(inifile, "UGDS", "GcFolder"));
+ if (s) {
+ s = gstrsub(s, "\\", "/");
+ xasprintf(&info->geo_path, "%s/%s", path, s);
+ }
+ s = xstrdup(inifile_readstr(inifile, "UGDS", "TrkFolder"));
+ if (s) {
+ s = gstrsub(s, "\\", "/");
+ xasprintf(&info->track_path, "%s/%s", path, s);
+ }
+ inifile_done(inifile);
+ xfree (inipath);
return info;
}
+mag_info *
+explorist_ini_get(const char **dirlist) {
+ mag_info *r = NULL;
+ while (dirlist && *dirlist) {
+ r = explorist_ini_try(*dirlist);
+ if (r) return r;
+ }
+ return r;
+}
+
void
explorist_ini_done(mag_info *info) {
xfree(info->geo_path);
char* waypoint_path;
} mag_info;
-mag_info * explorist_ini_get();
+mag_info * explorist_ini_get(const char **directory_list);
void explorist_ini_done(mag_info *info);
#include "gbser.h"
#include "explorist_ini.h"
+#if HAVE_GLOB
+#include <glob.h>
+#endif
+
static int bitrate = 4800;
static int wptcmtcnt;
static int wptcmtcnt_max;
// (This has nothing to do with the Explorist 100...600 products.)
static ff_vecs_t *gpx_vec;
static mag_info *explorist_info;
+static char ** os_gpx_files(const char *dirname);
/*
* Magellan's firmware is *horribly* slow to send the next packet after
static waypoint * mag_wptparse(char *);
typedef char * (cleanse_fn) (char *);
static cleanse_fn *mag_cleanse;
+static const char ** os_get_magellan_mountpoints();
static icon_mapping_t gps315_icon_table[] = {
{ "a", "filled circle" },
// We actually do the rd_init() inside read as we may have multiple
// files that we have to read.
if (0 == strcmp(portname, "usb:")) {
- char *vec_opts = NULL;
- explorist_info = explorist_ini_get();
- gpx_vec = find_vec("gpx", &vec_opts);
+ const char **dlist = os_get_magellan_mountpoints();
+ explorist_info = explorist_ini_get(dlist);
+ if (explorist_info) {
+ char *vec_opts = NULL;
+ gpx_vec = find_vec("gpx", &vec_opts);
+ }
return;
}
mag_read(void)
{
if (gpx_vec) {
- gpx_vec->rd_init(explorist_info->track_path);
- gpx_vec->read();
+ char **f = os_gpx_files(explorist_info->track_path);
+ while (f && *f) {
+ gpx_vec->rd_init(*f);
+ gpx_vec->read();
+ f++;
+ }
+
+ f = os_gpx_files(explorist_info->waypoint_path);
+ while (f && *f) {
+ gpx_vec->rd_init(*f);
+ gpx_vec->read();
+ f++;
+ }
+#if 0
+ f = os_gpx_files(explorist_info->geo_path);
+ while (f && *f) {
+ gpx_vec->rd_init(*f);
+ gpx_vec->read();
+ f++;
+ }
+#endif
return;
}
found_done = 0;
if (global_opts.masked_objective & TRKDATAMASK) {
magrxstate = mrs_handoff;
- if (!is_file)
+ if (!is_file)
mag_writemsg("PMGNCMD,TRACK,2");
-
+
while (!found_done) {
mag_readmsg(trkdata);
}
}
}
+const char ** os_get_magellan_mountpoints()
+{
+#if __APPLE__
+ const char **dlist = xcalloc(2, sizeof *dlist);
+ dlist[0] = xstrdup("/Volumes/Magellan");
+ dlist[1] = NULL;
+ return dlist;
+#else
+ fatal("Not implemented");
+#endif
+}
+
+// My kingdom for container classes and portable tree-walking...
+// Returns a pointer to a static vector that's valid until the next call.
+static char **
+os_gpx_files(const char *dirname)
+{
+#if HAVE_GLOB
+ static glob_t g;
+ char *path;
+ xasprintf(&path, "%s/*.gpx", dirname);
+ glob(path, 0, NULL, &g);
+ xfree(path);
+ return g.gl_pathv;
+#else
+ fatal("Not implemented");
+#endif
+}
+
/*
* This is repeated just so it shows up as separate menu options
* for the benefit of GUI wrappers.